package cn.tedu.rms.tables.controller;

import cn.tedu.rms.base.response.JsonResult;
import cn.tedu.rms.tables.pojo.dto.TablesQuery;
import cn.tedu.rms.tables.pojo.dto.TablesSaveParam;
import cn.tedu.rms.tables.pojo.vo.TablesVO;
import cn.tedu.rms.tables.service.TablesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/v1/tables")
@RestController
@Slf4j
public class TablesController {
    @Autowired
    //@Qualifier("tablesServiceImpl")
    private TablesService tablesService;

    @PostMapping("save")
    public JsonResult saveTables(TablesSaveParam tablesSaveParam){
        log.debug("保存餐桌，参数：{}",tablesSaveParam);
        tablesService.saveTables(tablesSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("deleteById/{id}")
    public JsonResult deleteById(@PathVariable Long id){
        log.debug("根据id删除餐桌，参数：{}",id);
        tablesService.deleteTablesById(id);
        return JsonResult.ok();
    }
    @GetMapping("select")
    public JsonResult selectTables(TablesQuery tablesQuery){
        log.debug("查询餐桌List，参数：{}",tablesQuery);
        List<TablesVO> tablesVOList = tablesService.selectTables(tablesQuery);
        return JsonResult.ok(tablesVOList);
    }
    @GetMapping("selectTablesForCustomer")
    public JsonResult selectTablesCustomer(TablesQuery tablesQuery){
        log.debug("顾客查询餐桌List，参数：{}",tablesQuery);
        List<TablesVO> tablesVOList = tablesService.selectTablesCustomer(tablesQuery);
        return JsonResult.ok(tablesVOList);
    }

}
